/**
 * 
 */
package speculoos.jndi.io;

import java.io.IOException;

/**
 * An interface for transforming Java objects into LDAP data 
 * and vice-versa.
 * <p>
 * Implementations of this interface are used by the {@link Object2LDAP} 
 * class for reading/writing LDAP queries into/from java objects.  
 * </p>
 * 
 * @author abailly
 * @see 
 */
public interface ObjectIO {

	/**
	 * Returns the LDAP representation of given object. 
	 * 
	 * @param o the object to serialize to LDAP
	 * @return the LDAP valid representation for this object
	 * @throws IOException if unable to serialize object
	 */
	public Object toLDAP(Object o) throws IOException;
	
	/**
	 * Returns the Java representation of given LDAP object.
	 * 
	 * @param o the LDAP value as stored in {@link javax.naming.directory.Attribute#get()}.
	 * @param c the target class
	 * @return the Java representation of this LDAP value.
	 * @throws IOException if unable to deserialize objects.
	 */
	public Object fromLDAP(Class c,Object o) throws IOException;
	
}
